<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
    <style>
        .div{
            text-align: center;
            margin-top: 50px;
        }
        .left{
            margin-left: 350px;
        }
    </style>
</head>
<body>
<form class="layui-form" action="/passWordCom" method="get">
    <div class="layui-form-item div">
        <div class="layui-inline">
            <label class="layui-form-label">原&nbsp;&nbsp;密&nbsp;&nbsp;码：</label>
            <div class="layui-input-inline">
                <input type="password" name="oldPassword" lay-verify="required|pass" autocomplete="off" class="layui-input">
            </div>
        </div><br><br>
        <div class="layui-inline">
            <label class="layui-form-label">新&nbsp;&nbsp;密&nbsp;&nbsp;码：</label>
            <div class="layui-input-inline">
                <input type="password" name="newPassword" id="password" lay-verify="required|pass" autocomplete="off" class="layui-input">
            </div>
        </div><br><br>
        <div class="layui-inline">
            <label class="layui-form-label">确认密码：</label>
            <div class="layui-input-inline">
                <input type="password" name="password" lay-verify="confirmPass|pass" autocomplete="off" class="layui-input">
            </div>
        </div><br><br>
    </div>
    <div class="layui-form-item left">
        <div class="layui-input-block">
            <!--<button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-->
            <input type="submit" class="layui-btn" value="立即提交">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script src="../layui/layui.js"></script>
<script src="../js/jquery-1.12.2.min.js"></script>

<script>
    layui.use(['form', 'layedit'], function() {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit;

        //自定义验证规则
        form.verify({
            pass: [
                /^[\S]{6}$/
                , '密码必须6位，且不能出现空格'
            ]
            ,confirmPass: function(value){
                if($("#password").val() !== value){
                    return '两次密码输入不一致！';
                }
            }
        });

        form.on('submit(demo1)', function(data){
            $.ajax({
                type:"post",
                url:"/hospital/doctor/updatePassword.do",
                data:$("form").serialize(),
                dataType:"json",
                success:function (data) {
                    if (data.code == 1) {
                        layer.msg(data.info);
                        $("form").empty();
                    }else {
                        layer.msg(data.info);
                    }
                }
            });
            return false;
        });



    })

</script>
</body>
</html>